dd if=/dev/zero of=rootfs-aarch64.ext4 bs=1M count=256

echo "hard disk partition!"
sgdisk -n 0:0:+16M -c 0:uboot rootfs-aarch64.ext4
sgdisk -n 0:0:+16M -c 0:kernel rootfs-aarch64.ext4
sgdisk -n 0:0:0 -c 0:rootfs rootfs-aarch64.ext4
sgdisk -p rootfs-aarch64.ext4

echo "mount loop device!"
LOOPDEV=`losetup -f`
echo $LOOPDEV
sudo losetup $LOOPDEV  rootfs-aarch64.ext4
sudo partprobe $LOOPDEV
sudo losetup -l
ls -l /dev/loop*

echo "format disk to ext4"
echo ${LOOPDEV}p1
echo ${LOOPDEV}p2
echo ${LOOPDEV}p3
sudo mkfs.ext4 ${LOOPDEV}p1
sudo mkfs.ext4 ${LOOPDEV}p2
sudo mkfs.ext4 ${LOOPDEV}p3
sudo mount -t ext4 ${LOOPDEV}p1 /mnt/uboot -o loop
sudo mount -t ext4 ${LOOPDEV}p2 /mnt/kernel -o loop
sudo mount -t ext4 ${LOOPDEV}p3 /mnt/rootfs -o loop
sudo cp -rf rootfs-aarch64/* /mnt/rootfs/
sudo cp vexpress-v2p-ca9/arch/arm/boot/dts/vexpress-v2p-ca9.dtb /mnt/kernel/
sudo cp vexpress-v2p-ca9/arch/arm/boot/uImage /mnt/kernel/
sudo umount /mnt/rootfs/
sudo umount /mnt/kernel/
sudo umount /mnt/uboot/
sudo losetup -d $LOOPDEV
